import { BrowserWindow } from 'electron'

const DevURL = 'http://localhost:8080'

export function reslove (url: string) {
  return url.startsWith('/') ? url : `/${url}`
}

export default function loadURL (browser: BrowserWindow, opts: WinOpts) {
  const route = reslove(opts.route)

  if (process.env.WEBPACK_DEV_SERVER_URL) {
    browser.loadURL(`${DevURL}/#${route}`)
  } else {
    browser.loadURL(`app://./index.html/#${route}`)
  }
}
